package com.cjm.one.goods.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.model.coupon.entity.CustomerCoupon;
import com.cjm.one.model.coupon.vo.CouponInfoVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author 29289
* @description 针对表【customer_coupon(乘客优惠券关联表)】的数据库操作Mapper
* @createDate 2024-09-05 15:59:26
* @Entity com.one.coupon.entity.CustomerCoupon
*/
@Mapper
public interface CustomerCouponMapper extends BaseMapper<CustomerCoupon> {

    Page<CustomerCoupon> listPage(Page<CustomerCoupon> customerCouponPage,@Param("keyword") String keyword,@Param("status") Integer status,@Param("userId") Long userId);

    Page<CouponInfoVo> selectCouponInfoAppReceivedPage(Page<CouponInfoVo> page,@Param("keyWord") String keyWord, @Param("rangeType") Integer rangeType,@Param("customerId") Long customerId);
    //获取用户已经使用了的 优惠券
    @Select("SELECT * FROM customer_coupon " +
                   "WHERE customer_id = #{userId} AND status = 2 OR  status = 0 and is_deleted = 0")
    List<CustomerCoupon> findValidCoupons(Long userId);

    int insertBatchSomeColumn(List<CustomerCoupon> collect);

    Integer selectReceivedCount(@Param("couponId") Long couponId, @Param("customerId") Long customerId);
}




